<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>解构赋值新增特性</title>
</head>
<body>
    <script>
        let user = {
            name : "xiasnn",
            age : 18
        };
        let {name:a,age:b} = user;
        console.log(a);

        // let {name:name,age:age} = user;
        // console.log(age);

        // 简写
        let {name,age} = user;
        console.log(name);



        function hd(){
            return {name1:'xiaxia',age1:19};
        }

        let {name1,age1} = hd();
        console.log(name1);


        function show({name,age}){
            console.log(name);
            console.log(age);
        }
        show({name:'大美女',age:20});



        // 如果有多个属性，可以只取其中一个
        let book = {
            name:"js",
            price:99
        }
        let {price} = book;
        console.log(price);


        // 取Math中的随机函数
        let {random} = Math;
        console.log(random());

    </script>
</body>
</html>